﻿using LxCFD;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LxCFD
{
    public class ConnectHeadBase : IConnectivityAnalyzableContact
    {
        public FvContactBase Contact;
        public FvPair[] Pairs;
        public IndexNumber InnerIndex;
        protected IndexNumber O_Index;
        protected IndexNumber N_Index;
        protected FvCell[] O_Cells;
        protected FvCell[] N_Cells;
        protected FvFace[] O_Faces;
        protected FvFace[] N_Faces;

        protected int deltaOFaceId;
        protected int deltaOCellId;
        protected int deltaNFaceId;
        protected int deltaNCellId;
        public virtual void CheckCreate(FvContactBase contact)
        {
            this.Contact = contact;
            this.InnerIndex = contact.InnerIndex;
            this.Pairs = contact.Pairs;
            contact.GetONZone(out FvZoneBase OZone, out FvZoneBase NZone);
            contact.GetONThread(out FvThreadBase OThread, out FvThreadBase NThread);
            this.O_Index = OThread.ThreadIndex;
            this.O_Cells = OZone.Cells;
            this.O_Faces = OZone.Faces;

            this.N_Index = NThread.ThreadIndex;
            this.N_Cells = NZone.Cells;
            this.N_Faces = NZone.Faces;

            deltaOFaceId = O_Index.FaceIDs.Start;
            deltaOCellId = O_Index.CellIDs.Start;
            deltaNFaceId = N_Index.FaceIDs.Start;
            deltaNCellId = N_Index.CellIDs.Start;

        }

        public void GetONZoneID(out int OZoneID, out int NZoneID)
        {
            Contact.GetONZone(out FvZoneBase OZone, out FvZoneBase NZone);
            OZoneID = OZone.ID;
            NZoneID = NZone.ID;
        }
    }
}